package com.mes.basicdata.service;


import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.bstek.dorado.annotation.DataProvider;
import com.bstek.dorado.data.provider.Page;
import com.mes.basicdata.dao.iface.IWorkCenterDao;
import com.mes.basicdata.domain.Operation;
import com.mes.basicdata.domain.WorkCenter;
import com.mes.common.service.BasicService;

@Service
public class WorkCenterService extends BasicService<WorkCenter> {

	@Autowired
	private IWorkCenterDao workCenterDao;
	
	@DataProvider
	public void getWorkCenters(Page<WorkCenter> page,  Map<String, Object> params) throws Exception{
		if (params != null){
			workCenterDao.getWorkCenterByConditions(page, params);
		}else {
			this.getAll(page);
		}
	}
	
	@DataProvider
	public WorkCenter getWorkCenterByDeviceUid(String deviceUid) throws Exception{
		return workCenterDao.getWorkCenterByDeviceUid(deviceUid);
	}
	
	@DataProvider
    public void getWorkCenterByConditions(Page<WorkCenter> page, Map<String, Object> params){
    	if (params != null && !params.equals("") ){
    		try {
    			workCenterDao.getWorkCenterByConditions(page, params);
    		} catch (Exception e) {
    			e.printStackTrace();
    		}
    	}else {
			try {
			//	this.getAll(page);
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
    }
	
	@DataProvider
	public void getWorkCentersByDept(Page<WorkCenter> page, Map<String, Object> params) throws Exception{
		if (params != null){
			workCenterDao.getWorkCentersByDept(page, params);
		}else {
			this.getAll(page);
		}
	}
}
